<template>
  <div class="Love">
    <van-nav-bar
      title="收藏列表"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
      :fixed="true"
      :placeholder="true"
      z-index="5"
    />
    <div class="card" v-for="(i,k) in station" :key="k">
        <ChargeStationCard 
            :point="i"
            :myposition="$store.state.myPosition"
            :distance="i.distance"
        />
    </div>

  </div>
</template>

<script>
import {get_loveStation,get_chargeStationby_id} from '@/api/index';
import ChargeStationCard from '@/components/ChargeStationCard/ChargeStationCard.vue'
export default {
  name: 'Love',
  components: {
      ChargeStationCard
  },
  props:[],
  data(){
        return{
            love: null,
            station: [],
        } 
    },
    computed:{
      adminuser(){
          return this.$store.state.adminuser;
      }
    },
    async created(){
      let res2 = await get_loveStation(this.adminuser)
       this.love = res2.data
       this.love.forEach(async item => {
         let res = await get_chargeStationby_id(item.charge_id) 
         this.station.push(res.data)
       });
    },
    watch:{
        
    },
    methods:{
        onClickLeft() {
            this.$router.go(-1);
        },
        /* plusReady(){
          const self = this
          console.log("plusReady--", plus.geolocation);
          plus.geolocation.getCurrentPosition(
            async function (p) {
              console.log("onPlusReady--p.coords", p.coords);
                        //初始化中心点和地图级别
            },
            function (err) {
              console.log("onPlusReady--err", err);
            }
          );
        }, */
    }
}
</script>

<style lang="less" scoped>
 .Love{
     .card{
        padding: 20px;
        background-color: white;
        border-radius: 10px;
        margin: 20px;
     }
 }
</style>